package com.ss.android.article.browser.c;

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.regex.Pattern;

public final class SystemShareHelper {
    private final Activity mActivity;

    static {
        Pattern.compile("(?i)((?:http|https|file)://|(?:inline|data|about|javascript):|(?:.*:.*@))(.*)");
    }

    public SystemShareHelper(@NonNull Activity activity) {
        this.mActivity = activity;
    }

    public final void invokeSystemShare(@Nullable String text, @Nullable String subject) {
        if(text != null && !SpecialPageHelper.isSpecialUrl(text)) {
            Intent intent = new Intent("android.intent.action.SEND");
            intent.setType("text/plain");
            if(subject != null) {
                intent.putExtra("android.intent.extra.SUBJECT", subject);
            }
            intent.putExtra("android.intent.extra.TEXT", text);
            this.mActivity.startActivity(Intent.createChooser(intent, this.mActivity.getString(com.ss.android.article.browser.R.string.if0)));
        }
    }
}

